<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="uct" uri="/WEB-INF/uct.tld" %>
<%@ taglib prefix="portal" uri="/WEB-INF/portal.tld" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <%@ include file="/common/sale/include/common-base.jsp"%>
  <title>商品登记管理-${titleName}</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
</head>

<!-- 以下是body主体内容的模块区域 -->
<body class="hold-transition ${sysColor} sidebar-mini">
<div class="wrapper">

  <!-- top start -->
  <%@include file="/common/sale/top.jsp" %>
  <!-- top end -->
  <!-- left start -->
  <%@include file="/common/sale/left.jsp" %>
  <!-- left end-->

  <div class="content-wrapper">
    <!-- Main start -->
	<section class="content">
      <div class="row">
        <div class="col-xs-12">
        
          <!------搜索  start ------->
          <div class="box box-info">
             <!--搜索title  start --> 
	          <div class="box-header with-border">
                 <h3 class="box-title"><i class="fa fa-search"></i> 商品登记搜索</h3>
                 <div class="box-tools pull-right" style="display: none;">
	                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
	                </button>
	                <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
                 </div>
              </div>
            <!--搜索title  end --> 
            <div class="box-body">
			  <form id="searchForm" class="form-horizontal">
				<input type="hidden" name="pageName" value="bjtesale-reg-list.jsp"/>
				<input type="hidden" name="formName" value="searchForm1">
				<input type="hidden" name="trpProduct.w_delStatus" value="F">
				<input type="hidden" name="trpProduct.w_cateNo" value="bjtesale"/>
				<input type="hidden" name="trpProduct.w_sysName" value="${sysName}"/>
				<input type="hidden" name="orderBy"  value="trpProduct.create_time desc" />
			 <div class="col-sm-11">
				<div class="form-group">
					<div class="col-sm-2 text_r"><label class="control-label" >商品代码：</label></div>
					<div class="col-sm-2">
						<input type="text" class="form-control clean"  name="trpProduct.wl_proNo" value="" id="search_proNo"/>
					</div>
					<div class="col-sm-2 text_r"><label class="control-label" >商品名称：</label></div>
					<div class="col-sm-2">
						<input type="text" class="form-control clean"  name="trpProduct.wl_proName" value="" id="search_proName"/>
					</div>
					<div class="col-sm-2 text_r"><label class="control-label" >商品状态：</label></div>
					<div class="col-sm-2">
						<select id="searchForm_trpProduct_proStatus" name="trpProduct.proStatus" class="form-control clean" 
               			data-url="doCode=dictItemList&cateEname=proStatus" data-colmun="" data-type="select">
               			</select>
					</div>
				</div>
				<center>
				   <div class="box-footer clearfix">
				       <button type="button" class="btn btn-success" onclick="getTableData();"><i class="fa fa-edit-circle"></i> 查询</button> 
				       <button  type="button" class="btn btn-warning" onclick="cleanData('searchForm');">重置 </button>
				   </div>
				</center>
			  </div>
			  </form>
            </div>
	     </div>
	     <!------- 搜索 end -------->
           
        <!------- 列表 start -------->
          <div class="box box-success">
            <!--列表title  start --> 
	          <div class="box-header with-border">
                 <h3 class="box-title"><i class="fa fa-user"></i> 商品登记列表 
                 　　　              <button  onclick="toAdd();" class="btn btn-success" type="button"><i class="fa fa-plus-circle"></i> 添加商品 </button>
                 </h3>
                 <div class="box-tools pull-right" style="display: none;">
	                 　　　　　　　　<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
	                </button>
	                <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
                 </div>
              </div>
            <!--列表title  end --> 
              <div class="box-body">
                <table id="dataList" class="table table-bordered table-hover" >
                <thead class="bg-success">
                <tr>
                        <th class="text_c">序号</th>
                        <th class="text_c">商品代码</th>
                        <th class="text_c">商品名称</th>
                        <th class="text_c">商品简称</th>
                        <th class="text_c">交易单位</th>
                        <th class="text_c">所属品种</th>
                        <th class="text_c">商品状态</th>
                        <th class="text_c">创建时间</th>
                  		<th class="text_c">操作</th>
                </tr>
                </thead>
                <tbody id="dataList-body">
                </tbody>
              </table>
              <center>
    	  		<ul id="dataList-page"></ul>
              </center>
            </div>
           </div>
        <!------- 列表 end -------->
        </div>
      </div>
    </section>
    <!-- Main end -->
  </div>
  <!-- /.content-wrapper -->
  <!-- foot start -->
  <%@include file="/common/sale/foot.jsp" %>
  <!-- foot start -->

<div class="modal fade" id="my_modal_add" tabindex="-1" data-backdrop="static" data-keyboard="false" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width: 800px">
				<div class="modal-content" >
					<div class="modal-header" >
						<button type="button" class="close"  data-dismiss="modal" aria-hidden="true" >
							×
						</button>
						<h4 class="modal-title">
							<font color="red">商品信息添加</font> 
						</h4>
					</div>

					<div class="modal-body">
						
					       <div class="nav-tabs-custom">
					            <ul class="nav nav-tabs" id="myTab">
					            </ul>
					            
					            <!-- tab content start -->
					            <div class="tab-content">
					            
					                  
					               <div class="tab-pane active" id="tab_1">
					                  <form class="form-horizontal" role="form" id="addForm1" action="javascript:void(0)">
					                    <input type="hidden" name="pageName" value="bjtesale-reg-list.jsp"/>
										<input type="hidden" name="formName" value="addForm1"/>
									    <input type="hidden" id="addForm1_formToken" name="formToken" />
										<input type="hidden" name="doCode" value="dymicSql"/>
										
							                <!--trpProduct start-->
										<input type="hidden" name="trpProduct.delStatus" value="F"/>
										<input type="hidden" name="trpProduct.sysName" id="addForm1_sysName" value="${sysName }"><!--所属系统-->
										<input type="hidden" name="trpProduct.cateId" value="9aac32f5cb19445f9b5fc6daf6db51b9"/>
										<input type="hidden" name="trpProduct.cateNo" value="bjtesale"/>
										<input type="hidden" name="trpProduct.cateName" value="北京木材"/>
										<input type="hidden" name="trpProduct.proStatus" value="0"/>
											
										<div class="row">
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-4 control-label">商品名称：</label>
												<div class="col-sm-8">
													<input type="text" id="addForm1_proName" data-name="trpProduct.proName" name="trpProduct.proName" maxLength="50" class="form-control clean"  placeholder="必填项"/>
												</div>
											</div>
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-4 control-label">商品代码：</label>
												<div class="col-sm-8">
													<input type="text" id="addForm1_proNo" data-name="trpProduct.proNo" name="trpProduct.proNo" class="form-control clean" maxLength="6" placeholder="6位数字"  onchange="checkProNo();"/>
												</div>
											</div> 
										</div>
										<div class="row">
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-4 control-label">商品简称：</label>
												<div class="col-sm-8">
													<input type="text" id="addForm1_shortName" data-name="trpProduct.shortName"  maxLength="10" name="trpProduct.shortName" class="form-control clean"  placeholder="最多输入10个字" />
												</div>
											</div>
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-4 control-label">交易单位：</label>
												<div class="col-sm-8">
													<select id="addForm1_proUnit" data-name="trpProduct.proUnit" name="trpProduct.proUnit" class="form-control clean" 
						                			data-url="doCode=dictItemList&cateEname=productUnit" data-colmun="" data-type="select" >
						                			</select>
												
												</div>
											</div>
										</div>
										<div class="row">
						                	<div class="form-group col-sm-12" >
												<label  class="col-sm-2 control-label" style="margin-left: -5px;">商品描述：</label>
												<div class="col-sm-10">
										  			<textarea class="form-control clean" style="width: 570px;" rows="4" data-name="trpProduct.proRemark" id="addForm1_proRemark" name="trpProduct.proRemark"  maxLength="200" placeholder="最多输入200字"></textarea>
												</div>
											</div>
										</div> 
											<!--  
						                	<div class="form-group col-sm-12" style="">
												<label  class="col-sm-2 control-label">商品状态</label>
												<div class="col-sm-10">
						                			<select id="addForm1_trpProduct_proStatus" data-name="trpProduct.proStatus" name="trpProduct.proStatus" class="form-control clean" 
						                			data-url="doCode=dictItemList&cateEname=proStatus" data-colmun="" data-type="select" >
						                			</select>
												</div>
											</div>
											  --> 
								        	<!--trpProduct end-->
								        
					                    
					                    <div class="form-group">
								        	<div class="col-sm-12">
									         <div class="box-footer text-center">
									         	<button class="btn btn-danger" type="button" style="width: 200px;" onclick="submitForm1('addForm1');"> 保存 </button>
					            			</div>
				            				</div>
				            			</div>
					                  </form>
					               </div>
					          
				            </div>
					            <!-- tab content e -->
				          </div>	
			                
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>  

<div class="modal fade" id="my_modal_edit" tabindex="-1" data-backdrop="static" data-keyboard="false" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width: 800px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true" >
							×
						</button>
						<h4 class="modal-title">
							<font color="red">商品信息修改</font> 
						</h4>
					</div>
					<div class="modal-body">
						<div class="nav-tabs-custom">
					            <ul class="nav nav-tabs" id="myTab">
					            </ul>
					            
					            <!-- tab content start -->
					            <div class="tab-content">
					            
					                  
					               <div class="tab-pane active" id="edit_tab_1">
					                  <form class="form-horizontal" role="form" id="editForm1" action="javascript:void(0)">
					                    <input type="hidden" name="pageName" value="bjtesale-reg-list.jsp"/>
										<input type="hidden" name="formName" value="editForm1"/>
									    <input type="hidden" id="editForm1_formToken" name="formToken" />
										<input type="hidden" name="doCode" value="dymicSql"/>
					        			<input type="hidden" data-name="trpProduct.proId" name="trpProduct.w_proId" id="editForm1_w_proId" value=""><!--this is primaryKeyId 主键-->
										
							                <!--trpProduct start-->
										<div class="row">
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-4 control-label">商品名称：</label>
												<div class="col-sm-8">
														<input type="text" id="editForm1_proName" data-name="trpProduct.proName" name="trpProduct.proName" class="form-control clean"  placeholder="必填项" />
												</div>
											</div>
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-4 control-label">商品代码：</label>
												<div class="col-sm-8">
														<input type="text" id="editForm1_proNo" data-name="trpProduct.proNo" name="trpProduct.proNo"  maxlength="6"  class="form-control clean"  placeholder="必填项" readonly="readonly"/>
												</div>
											</div>
										</div>
										<div class="row">
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-4 control-label">商品简称：</label>
												<div class="col-sm-8">
														<input type="text" id="editForm1_shortName" data-name="trpProduct.shortName" name="trpProduct.shortName" maxlength="10" class="form-control clean"  placeholder="最多输入10个字" />
												</div>
											</div>
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-4 control-label">交易单位：</label>
												<div class="col-sm-8">
														<select id="editForm1_proUnit" data-name="trpProduct.proUnit" name="trpProduct.proUnit" class="form-control" 
							                			data-url="doCode=dictItemList&cateEname=productUnit" data-colmun="" data-type="select" >
							                			</select>
												</div>
											</div>
										</div>
										<div class="row">
						                	<div class="form-group col-sm-12">
												<label  class="col-sm-2 control-label" style="margin-left: -5px;">商品描述：</label>
												<div class="col-sm-10">
										  			<textarea class="form-control clean" style="width: 570px;" rows="6" data-name="trpProduct.proRemark" id="form1_proRemark" name="trpProduct.proRemark"  maxLength="200" placeholder="最多输入200字"  data-type="textarea" ></textarea>
												</div>
											</div>
										</div>
											<!-- 
						                	<div class="form-group col-sm-10">
												<label  class="col-sm-4 control-label">商品状态</label>
												<div class="col-sm-8">
						                			<select id="editForm1_trpProduct_proStatus" data-name="trpProduct.proStatus" name="trpProduct.proStatus" class="form-control" 
						                			data-url="doCode=dictItemList&cateEname=proStatus" data-colmun="" data-type="select" disabled="disabled">
						                			</select>
												</div>
											</div>
											 -->
								        	<!--trpProduct end-->
								        
					                    
					                    <div class="form-group">
								        	<div class="col-sm-12">
									         <div class="box-footer text-center">
									         	<button class="btn btn-danger" type="button" style="width: 200px;" onclick="submitForm1('editForm1');"> 保存 </button>
					            			</div>
				            				</div>
				            			</div>
					                  </form>
					               </div>
					          
				            </div>
					            <!-- tab content e -->
				          </div>	
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>  

<div win-title="查看窗口" class="modal fade" id="my_modal_view" tabindex="-2" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width: 800px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">商品信息查看</font> 
						</h4>
					</div>
					<div class="modal-body">
						<div class="nav-tabs-custom">
					            <ul class="nav nav-tabs" id="viewmyTab">
					            </ul>
					            
					            <!-- tab content start -->
					            <div class="tab-content">
					                  
					               <div class="tab-pane active" id="view_tab_1">
					                  <form class="form-horizontal" role="form" id="viewForm1" action="javascript:void(0)">
							                <!--trpProduct start-->
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-4 control-label">商品名称：</label>
												<div class="col-sm-8 control-label1" >
													<span data-name="trpProduct.proName"  ></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-4 control-label">商品代码：</label>
												<div class="col-sm-8 control-label1">
													<span data-name="trpProduct.proNo"></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-4 control-label">商品简称：</label>
												<div class="col-sm-8 control-label1">
													<span data-name="trpProduct.shortName"></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-4 control-label">交易单位：</label>
												<div class="col-sm-8 control-label1">
													<span data-name="trpProduct.proUnit" data-dict-url="doCode=dictItemList&cateEname=productUnit"></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-4 control-label">商品状态：</label>
												<div class="col-sm-8 control-label1">
						                			<span data-name="trpProduct.proStatus" data-dict-url="doCode=dictItemList&cateEname=proStatus"></span>
												</div>
											</div>
											
						                	<div class="form-group col-sm-6">
												<label  class="col-sm-4 control-label">商品描述：</label>
												<div class="col-sm-8 control-label1">
													<span data-name="trpProduct.proRemark"></span>
												</div>
											</div>
											
								        	<!--trpProduct end-->
								        
					                    
					                    <div class="form-group">
								        	<div class="col-sm-12">
									         <div class="box-footer text-center">
									         	<button class="btn btn-danger" type="button" style="width: 200px;" onclick="cannel('view');"> 关闭 </button>
					            			</div>
				            				</div>
				            			</div>
					                  </form>
					               </div>
					          
				            </div>
					            <!-- tab content e -->
				          </div>	
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>
</body>


<!-- 以下是template列表模板的模块区域 -->
<script type="text/template" id="dataList-template">
		<? for ( var i = 0; i < rows.length; i++) {?>
		<tr>
			<td class="text_c"><?=(pageObj.currentPage-1)*10+(i+1)?></td>
			<td class="text_c"><?=strUtil.doNull(rows[i].proNo,'')?></td>
            <td class="text_l"><?=strUtil.subStr(rows[i].proName,10)?></td>
			<td class="text_l"><?=strUtil.subStr(rows[i].shortName,10)?></td>
			<td class="text_c"><?=DictUtil.getDictNameByFile("productUnit",0,rows[i].proUnit)?></td>
			<td class="text_c"><?=strUtil.doNull(rows[i].cateName,'')?></td>
			<td class="text_c">
              	<?=DictUtil.getDictNameByFile("proStatus",0,rows[i].proStatus)?>&nbsp;
            </td>
			<td class="text_c"><?=strUtil.doNull(rows[i].createTime,'')?></td>
            <td class="text_l">
					<button type="button" class="btn btn-success btn-xs" onclick="toLoad1('<?=rows[i].proId?>','view')">查看</button>  
			<?if(rows[i].proStatus=='0'){?>	
					<button type="button" class="btn btn-warning btn-xs" onclick="toLoad1('<?=rows[i].proId?>','edit');">修改</button>  
					<button type="button" class="btn btn-danger btn-xs" onclick="toDele('<?=rows[i].proId?>');">删除</button>  
					<button type="button" class="btn btn-primary btn-xs" onclick="toSale('<?=rows[i].cateNo?>','<?=rows[i].proId?>','<?=rows[i].proNo?>','<?=rows[i].proName?>');"><i class="fa fa-plus-circle"></i> 添加发行</button>   
			<?}?> 
			<!--<?if(rows[i].proStatus=='10'){?>		
					<button type="button" class="btn btn-primary btn-xs" onclick="toSale('<?=rows[i].cateNo?>','<?=rows[i].proId?>','<?=rows[i].proNo?>','<?=rows[i].proName?>');"><i class="fa fa-search"></i> 查看发行</button>
			<?}?>
				-->
			 </td>
		</tr>
   <?}?>  		
</script>

</html>

<!-- 以下是js模块区域 -->
<script>
var clickMenu = "bjtesale-reg-list";
var id,myPage,dataListId,searchFormId,isShowLog,tableSort,tableId,token;
myPage = 10;
dataListId = "dataList";
searchFormId = "searchForm";
tableSort = "trpProduct";
tableId = "proId";
isShowLog = true;

$(function () {
	//1、加载分页列表数据
	DictUtil.getCommonDictData("select","#searchForm_trpProduct_proStatus","trpProduct.proStatus","doCode=dictItemList&cateEname=proStatus","","");
	getTableData();
	//2、控制是否启用token
	setToken();
	
	
	//请在下面补充其他初始化方法（如数据字典、页面加载数据等）
	//3、初始化数据字典
	//$("#addForm1_trpProduct_proStatus   option[value='"+A+"']").attr("selected",true);
	DictUtil.getCommonDictData("select","#addForm1_proUnit","trpProduct.proUnit","doCode=dictItemList&cateEname=productUnit","","");
	DictUtil.getCommonDictData("select","#editForm1_proUnit","trpProduct.proUnit","doCode=dictItemList&cateEname=productUnit","","");
 });
 
var dateObject = $('.datepicker').datepicker( {
	language : 'zh-CN',
	//inline: true,
	todayBtn : "linked",
	format : "yyyy-mm-dd",
	autoclose: true
});
//toLoad1 读取（查询、编辑）数据
function toLoad1(id,type){
	var paramLoadData = {"formName":"searchForm1","pageName":"bjtesale-reg-list.jsp","trpProduct.w_proId":id};
	showModal(type);
	$.ajax({
	    type:'get',
	   	url:common_info_url+"?doCode=dymicSql",
	    data: paramLoadData,
	    async:false,
	    dataType:"json",
	    success: function(myData){
	    	console.log(myData);
	    	
			//FormUtil.loadView("trpProduct", myData.trpProduct);
			FormUtil.loadView("trpProduct", myData);
			DictUtil.getCommonDictData("select","#editForm1_trpProduct_proStatus","trpProduct.proStatus","doCode=dictItemList&cateEname=proStatus","",myData.trpProduct.proStatus);
			 
	  	}
	});
}

function toDele(id){
	setToken();
	var index_submit = layer.confirm('您确定要删除信息吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		var paramLoadData = {"pageName":"trp-product","formName":"delForm","trpProduct.w_proId":id,"formToken":token};
		//var paramLoadData = {"modelTypes":"u_trpProduct","trpProduct.delStatus":"T","trpProduct.w_proId":id};
		doDele(paramLoadData);
	});
}
//弹框
function showModal(type){
	if("view"==type){
		$("#my_modal_view").modal("show");
	}else if("edit"==type){
		//修改弹框时，初始化数据字典
		cleanData('editForm1');
		setValidate("editForm1");//2.校验规则-弹框窗口加载定义方法
		DictUtil.getCommonDictData("select","#editForm1_trpProduct_proStatus","trpProduct.proStatus","doCode=dictItemList&cateEname=proStatus","","");
		$("#my_modal_edit").modal("show");
	}
}

$(function () {
	$('#'+dataListId+' tbody').on('click','tr', function (e) {
	     if ( $(this).hasClass('selected') ) {
	            //$(this).removeClass('selected');
	        }
	        else {
	            $('tr.selected').removeClass('selected');
	            $(this).addClass('selected');
	        }
	     id = $('tr.selected td').eq(0).html();
	   //  console.log($('tr.selected td').eq(1).html())
	} );
	
	
  });
//加载列表数据
function getTableData(){
	
	//搜索框去除空格
	$("#search_proNo").val($("#search_proNo").val().trim());
	$("#search_proName").val($("#search_proName").val().trim());
	
	deleteAllRow(dataListId);
	$.ajax({
		   type:'get',
		   url:common_list_url,
		   data:$("#"+searchFormId).serialize()+getCurrentPage(common_list_url+"?"+$("#"+searchFormId).serialize(),myPage),
		   dataType:'json',
		   success: function(myData){
		   if(isShowLog)console.log(myData);
			var data = baidu.template(dataListId+"-template",eval(myData));  
			$("#"+dataListId+"-body").html(data);
			  var option= {
					   ele:$("#"+dataListId+"-page")[0],
					   total:myData.total,
					   fn:getTableData,
					   url:common_list_url+"?"+$("#"+searchFormId).serialize()
				   }
				generatePages(option);
		   }
		});	
  }

//设置模态框隐藏事件 
$( '#my_modal_add' ).on( 'show.bs.modal' ,function(e){  
	cleanJiaoyan("addForm1");
	$("#addForm1_proNo").nextAll("span").remove();
});
//修改窗口，点击空白处校验未清空，设置修改窗口再次打开时清空校验
$( '#my_modal_edit' ).on( 'show.bs.modal' ,function(e){  
	cleanJiaoyan("editForm1");
}); 
//清空数据
function cleanData(id){
	$('#'+id).find(".clean").val("");//按照样式清空；
}
//打开添加页面
function toAdd(){
	cleanData('addForm1');//清空模态窗口内数据
	setValidate("addForm1");//2.校验规则-弹框窗口加载定义方法
	$("#w_"+tableId).val("");
	$(".datepicker").val("");
	$('#my_modal_add').modal('show');
}

//获取对象值
function loadObj(type,paramData){
	$.ajax({
	    type:'get',
	   	url:common_info_url+"?doCode=dymicSql",
	    data: paramData,
	    async:false,
	    dataType:"json",
	    success: function(myData){
	    	showData(type,myData);
	  	}
	});	
}

//删除信息（逻辑删除）
function doDele(paramData){
	$.ajax({
	    type:"post",
	    url:common_submit_url+"?doCode=dymicSql",
	    data: paramData,
	    dataType:"json",
	    success: function(myData){
	    	var result = myData.flag;
	    	if(result=="T"){
	    		layer.alert("删除操作成功");
	    		refresh();
	    	}
	  	}
	});	
}

//关闭窗口时清空校验规则
function cleanJiaoyan(formId){
		var validate = $('#'+formId).data('bootstrapValidator').validate();
		validate.resetForm();
}

function submitForm1(formId,tabId){
	//3.校验规则-表单提交时触发
	var validate = $('#'+formId).data('bootstrapValidator').validate();
	if(!validate.isValid()){ //如果校验不通过
	    return;  
	} 
	
	var index_submit = layer.confirm('您确定要保存信息吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		var result = submitForm(formId,tabId);
		if(result){
			
			if(result.flag=='T'){
	    		var num = formId.slice(-1);
	    		if(num!=null &&　num !=""){
	    			num=parseInt(num)+1;
	    			defaultTab = "#tab_"+num;
	    		}
	      		layer.alert('操作成功！', {closeBtn: 0});
	      		validate.resetForm();//提交成功后，删除校验方法
	      		cannel('');
	      		cannel("edit");
	      		refresh();
	      		//setToken();
	      		//if(tabId!=null && tabId!=""){
	      		//	tabId = "#"+tabId;
	      		//	$('#myTab a[href=\"'+tabId+'\"]').tab('show'); // Select tab by name 
	      		//}
		     }
		}
		
	});
 }
	

 

function submitForm(formId,tabId){
	var result;
	var index_load = layer.load(1, {shade: false});
	$.ajax({
	    type:'post',
	    url:common_submit_url,
	    data:$("#"+formId).serialize(),
	    async:false,
	    dataType:'json',
	    success: function(myData){ 
	     console.log(myData);
	        if(myData.flag=="T"){
	        result = myData;
	        if(myData.ids){
	           // proId = primaryId;
	        	////myData.ids={myData.ids.trpPro_proId=?;myData.ids.trpPub_pubId=?;myData.ids.pubLandContract_infoId=?}
	        	//for(var objstr in myData.ids){
	        		////alert(objstr.replace('_','w_')+"-"+myData.ids[objstr]);
	        	//	var pkName = objstr.replace('_','.w_');
	        	//	$("input[name='"+pkName+"'").val(myData.ids[objstr]);
	        	//}
	        	
	        }
	    	}else{
	     		layer.alert(myData.msg, {
	    		    closeBtn: 0
	    		  });
	    	}
	        layer.close(index_load);

	  	},
	     error: function (e) {
		     layer.close(index_load);
     	} 
	});	
	return result;
}


//关闭win
function cannel(type){
	if(strUtil.isNull(type)){
		$('#my_modal_add').modal('hide');
	}else{
		$('#my_modal_'+type).modal('hide');
	}
}

function refresh(){
	getTableData();
	setToken();
}

/****  以下是自定义新增方法  ****/
//进入一级发行活动
function toSale(cateNo,proId,proNo,proName){
	var url="${page_admin}/sale/"+cateNo+"-pub-list?proId="+proId+"&cateNo="+cateNo+"&proNo="+proNo+"&proName="+proName;
	window.location.href=encodeURI(url);	
}
//查看申购历史记录
function toBuy(cateNo,proId,proNo,proName){
	var url="${page_admin}/sale/"+cateNo+"-buy-list?proId="+proId+"&proNo="+proNo+"&proName="+proName;
	window.location.href=encodeURI(url);	
}
//流通二级市场交易
function toTrans(cateNo,proId,proNo,proName){
	var url="${page_admin}/trans/"+cateNo+"-trans-list?proId="+proId+"&proNo="+proNo+"&proName="+proName;
	window.location.href=encodeURI(url);
}

//1.校验规则-定义
function setValidate(formId){
	$('#'+formId).bootstrapValidator({
	   // excluded: [':disabled'],
	    feedbackIcons: {
	        valid: 'glyphicon glyphicon-ok',
	        invalid: 'glyphicon glyphicon-remove',
	        validating: 'glyphicon glyphicon-refresh'
	    },
	    fields: {
	        "trpProduct.proName": {
	            validators: {
	                notEmpty: {
	                    message: '商品名称不能为空！'	
	                }
	            }
	        },
	       "trpProduct.proNo":{
	        	validators: {
			        notEmpty: {
		                message: '商品代码不能为空！'
		               },
		            regexp: {
                        regexp: /^[0-9]{6}$/,
                        message: '请填写6位数数字！'
                    }
		           
	            }
	        },
	        "trpProduct.shortName":{
	        	validators: {
	                notEmpty: {
	                    message: '商品简称不能为空！'
	                }
	            }
	        },
	        "trpProduct.proUnit": {
	            validators: {
	                notEmpty: {
	                    message: '交易单位不能为空！'	
	                }
	            }
	        },
	    }
	});
}


function editStatus(proId,status,msg){
	
	var index_submit = layer.confirm('您确定要将此商品进行'+msg+'处理吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		var paramData={"trpProduct.w_proId":proId,"tQuotation.w_proId":proId,"trpProduct.proStatus":status,"tQuotation.status":status,"modelTypes":"u_trpProduct,u_tQuotation"};
		$.ajax({
		    type:"post",
		    url:common_submit_url+"?doCode=dymicSql",
		    data: paramData,
		    dataType:"json",
		    success: function(myData){
		    	var result = myData.flag;
		    	if(result=="T"){
		    		layer.alert("操作成功");
		    		refresh();
		    	}
		  	}
		});	
	});
}

function checkProNo(){
	var proNo = $("#addForm1_proNo").val().trim();
    if(strUtil.isNull(proNo)){
        return;
    }
	$.ajax({
		url:common_list_url,
		type:"get",
		data:{"pageName":"bjtesale-reg-list.jsp","formName":"searchForm1","trpProduct.w_proNo":proNo},
		dataType:"json",
		success:function(myData){
			if(myData.flag=="T"){
				$("#addForm1_proNo").nextAll("span").remove();
				if(myData.total>0){
					$("#addForm1_proNo").after("<span style='color:#a94442'>商品代码已被使用，请重新输入</span>");
					$("#addForm1_proNo").val("");
				}
			}else{
				layer.alert("操作失败");
			}
		}
	});
}
</script>